namespace Ds.DataBase.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class _20200713002 : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.PersonalMains",
                c => new
                    {
                        pmid = c.Int(nullable: false, identity: true),
                        cjsj = c.DateTime(nullable: false),
                        sssj = c.DateTime(nullable: false),
                        mobanid = c.Int(nullable: false),
                        ssrid = c.Guid(nullable: false),
                        state = c.Int(nullable: false),
                        tableName = c.String(),
                        PersonalWorkSummary_wsid = c.Int(),
                    })
                .PrimaryKey(t => t.pmid)
                .ForeignKey("dbo.PersonalWorkSummaries", t => t.PersonalWorkSummary_wsid)
                .Index(t => t.PersonalWorkSummary_wsid);
            
            CreateTable(
                "dbo.AdditionalItems",
                c => new
                    {
                        fjxid = c.Int(nullable: false, identity: true),
                        xmid = c.Int(nullable: false),
                        xmmc = c.String(),
                        xmfz = c.Decimal(nullable: false, precision: 18, scale: 2),
                        cjrid = c.Guid(nullable: false),
                        cjsj = c.DateTime(nullable: false),
                        PersonalMain_pmid = c.Int(),
                    })
                .PrimaryKey(t => t.fjxid)
                .ForeignKey("dbo.PersonalMains", t => t.PersonalMain_pmid)
                .Index(t => t.PersonalMain_pmid);
            
            CreateTable(
                "dbo.PersonalPaths",
                c => new
                    {
                        ppid = c.Int(nullable: false, identity: true),
                        shunxu = c.Int(nullable: false),
                        ljmc = c.String(),
                        paths = c.String(),
                        fenzhi = c.Decimal(nullable: false, precision: 18, scale: 2),
                        mpid = c.Int(nullable: false),
                        ControlID = c.Int(nullable: false),
                        isEdit = c.Boolean(nullable: false),
                        isinclude = c.Boolean(nullable: false),
                        sonmobanid = c.Int(nullable: false),
                        sonmobanfenzhi = c.Decimal(nullable: false, precision: 18, scale: 2),
                        PersonalMain_pmid = c.Int(),
                    })
                .PrimaryKey(t => t.ppid)
                .ForeignKey("dbo.PersonalMains", t => t.PersonalMain_pmid)
                .Index(t => t.PersonalMain_pmid);
            
            CreateTable(
                "dbo.PersonalContents",
                c => new
                    {
                        pcid = c.Int(nullable: false, identity: true),
                        shunxu = c.Int(nullable: false),
                        nr = c.String(),
                        fenzhi = c.Decimal(nullable: false, precision: 18, scale: 2),
                        cjsj = c.DateTime(nullable: false),
                        isedit = c.Boolean(nullable: false),
                        kssj = c.DateTime(nullable: false),
                        jssj = c.DateTime(nullable: false),
                        wcqk = c.String(),
                        iswc = c.Boolean(nullable: false),
                        zpf = c.Decimal(nullable: false, precision: 18, scale: 2),
                        zhou = c.Int(nullable: false),
                        ljcs = c.Int(nullable: false),
                        gzcdrid = c.Guid(nullable: false),
                        cjrid = c.Guid(nullable: false),
                        laiyuan = c.Int(nullable: false),
                        PersonalOrigin_pmid = c.Int(nullable: false),
                        PersonalOrigin_pcid = c.Int(nullable: false),
                        PersonalOrigin_lyxingming = c.String(),
                        PersonalPath_ppid = c.Int(),
                    })
                .PrimaryKey(t => t.pcid)
                .ForeignKey("dbo.PersonalPaths", t => t.PersonalPath_ppid)
                .Index(t => t.PersonalPath_ppid);
            
            CreateTable(
                "dbo.PersonalAnswers",
                c => new
                    {
                        paid = c.Int(nullable: false, identity: true),
                        shunxu = c.Int(nullable: false),
                        tips = c.String(),
                        fenzhi = c.Decimal(nullable: false, precision: 18, scale: 2),
                        html = c.String(),
                        PersonalContent_pcid = c.Int(),
                    })
                .PrimaryKey(t => t.paid)
                .ForeignKey("dbo.PersonalContents", t => t.PersonalContent_pcid)
                .Index(t => t.PersonalContent_pcid);
            
            CreateTable(
                "dbo.PersonalEnclosures",
                c => new
                    {
                        fjid = c.Int(nullable: false, identity: true),
                        path = c.String(),
                        fjmc = c.String(),
                        content = c.String(),
                        fileguid = c.String(),
                        fileHash = c.String(),
                        PersonalContent_pcid = c.Int(),
                    })
                .PrimaryKey(t => t.fjid)
                .ForeignKey("dbo.PersonalContents", t => t.PersonalContent_pcid)
                .Index(t => t.PersonalContent_pcid);
            
            CreateTable(
                "dbo.PersonalEvaluates",
                c => new
                    {
                        pjid = c.Int(nullable: false, identity: true),
                        pjrid = c.Guid(nullable: false),
                        fz = c.Decimal(nullable: false, precision: 18, scale: 2),
                        iseffective = c.Boolean(nullable: false),
                        cjsj = c.DateTime(nullable: false),
                        PersonalContent_pcid = c.Int(),
                    })
                .PrimaryKey(t => t.pjid)
                .ForeignKey("dbo.PersonalContents", t => t.PersonalContent_pcid)
                .Index(t => t.PersonalContent_pcid);
            
            CreateTable(
                "dbo.RelevantWorks",
                c => new
                    {
                        xggzid = c.Int(nullable: false, identity: true),
                        pcid = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.xggzid)
                .ForeignKey("dbo.PersonalContents", t => t.pcid, cascadeDelete: true)
                .Index(t => t.pcid);
            
            CreateTable(
                "dbo.PersonalWorkSummaries",
                c => new
                    {
                        wsid = c.Int(nullable: false, identity: true),
                        zjmc = c.String(),
                        cjsj = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.wsid);
            
            CreateTable(
                "dbo.WorkSummaryItems",
                c => new
                    {
                        wsiid = c.Int(nullable: false, identity: true),
                        zjlx = c.Int(nullable: false),
                        cjsj = c.DateTime(nullable: false),
                        zjnr = c.String(),
                        PersonalWorkSummary_wsid = c.Int(),
                    })
                .PrimaryKey(t => t.wsiid)
                .ForeignKey("dbo.PersonalWorkSummaries", t => t.PersonalWorkSummary_wsid)
                .Index(t => t.PersonalWorkSummary_wsid);
            
            CreateTable(
                "dbo.PersonalMainStateLogs",
                c => new
                    {
                        id = c.Int(nullable: false, identity: true),
                        cjrid = c.Guid(nullable: false),
                        cjsj = c.DateTime(nullable: false),
                        msg = c.String(),
                        isread = c.Boolean(nullable: false),
                        PersonalState = c.Int(nullable: false),
                        PersonalMain_pmid = c.Int(),
                    })
                .PrimaryKey(t => t.id)
                .ForeignKey("dbo.PersonalMains", t => t.PersonalMain_pmid)
                .Index(t => t.PersonalMain_pmid);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.PersonalMainStateLogs", "PersonalMain_pmid", "dbo.PersonalMains");
            DropForeignKey("dbo.PersonalMains", "PersonalWorkSummary_wsid", "dbo.PersonalWorkSummaries");
            DropForeignKey("dbo.WorkSummaryItems", "PersonalWorkSummary_wsid", "dbo.PersonalWorkSummaries");
            DropForeignKey("dbo.PersonalPaths", "PersonalMain_pmid", "dbo.PersonalMains");
            DropForeignKey("dbo.PersonalContents", "PersonalPath_ppid", "dbo.PersonalPaths");
            DropForeignKey("dbo.RelevantWorks", "pcid", "dbo.PersonalContents");
            DropForeignKey("dbo.PersonalEvaluates", "PersonalContent_pcid", "dbo.PersonalContents");
            DropForeignKey("dbo.PersonalEnclosures", "PersonalContent_pcid", "dbo.PersonalContents");
            DropForeignKey("dbo.PersonalAnswers", "PersonalContent_pcid", "dbo.PersonalContents");
            DropForeignKey("dbo.AdditionalItems", "PersonalMain_pmid", "dbo.PersonalMains");
            DropIndex("dbo.PersonalMainStateLogs", new[] { "PersonalMain_pmid" });
            DropIndex("dbo.WorkSummaryItems", new[] { "PersonalWorkSummary_wsid" });
            DropIndex("dbo.RelevantWorks", new[] { "pcid" });
            DropIndex("dbo.PersonalEvaluates", new[] { "PersonalContent_pcid" });
            DropIndex("dbo.PersonalEnclosures", new[] { "PersonalContent_pcid" });
            DropIndex("dbo.PersonalAnswers", new[] { "PersonalContent_pcid" });
            DropIndex("dbo.PersonalContents", new[] { "PersonalPath_ppid" });
            DropIndex("dbo.PersonalPaths", new[] { "PersonalMain_pmid" });
            DropIndex("dbo.AdditionalItems", new[] { "PersonalMain_pmid" });
            DropIndex("dbo.PersonalMains", new[] { "PersonalWorkSummary_wsid" });
            DropTable("dbo.PersonalMainStateLogs");
            DropTable("dbo.WorkSummaryItems");
            DropTable("dbo.PersonalWorkSummaries");
            DropTable("dbo.RelevantWorks");
            DropTable("dbo.PersonalEvaluates");
            DropTable("dbo.PersonalEnclosures");
            DropTable("dbo.PersonalAnswers");
            DropTable("dbo.PersonalContents");
            DropTable("dbo.PersonalPaths");
            DropTable("dbo.AdditionalItems");
            DropTable("dbo.PersonalMains");
        }
    }
}
